extends "../../azurlane_ctrl/AzurItem.gd"
func init():
	.init()
	price = 300
	name = "[稀有]拟态金属"
	flag = true
	rollAtt()
	info = "所有属性随机，被装备之前，每回合会变化一次属性"
	if sys.main != null and not sys.main.is_connected("onBattleReady",self,"rollAtt"):
		sys.main.connect("onBattleReady", self, "rollAtt")

var flag = true
func _connect():
	._connect()
	flag = false
	if masCha.team != 1:
		att.mgiAtk = 100
		att.atk = 100
	info = "属性已固定"

func setAtt(name, minValue, maxValue, chance, isFloat=false):
	if sys.rndPer(chance):
		if not isFloat:
			att.set(name, sys.rndRan(minValue, maxValue))
		else:
			att.set(name, sys.rndRan(minValue, maxValue)/100.0)
		yield(sys.get_tree().create_timer(0.03), "timeout")
		
func clearAtt():
	attInit()

func rollAtt():
	if not flag:return
	clearAtt()
	if sys.rndPer(30):
		att.maxHp = sys.rndRan(100, 1000)
	else:
		att.maxHp = 0

	setAtt("atk", 20, 80, 50)
	setAtt("mgiAtk", 20, 80, 50)
	setAtt("air", 20, 100, 50)
	setAtt("spd", 10, 60, 30, true)
	setAtt("suck", 10, 40, 10, true)
	setAtt("penL", 10, 30, 10, true)
	setAtt("cri", 20, 40, 15, true)
	setAtt("criR", 20, 40, 15, true)
	setAtt("cd", 20, 40, 15, true)
	setAtt("maxHp", 100, 600, 40)
	setAtt("def", 10, 80, 30)
	setAtt("dod", 10, 50, 20)

# #name, min, max, chance, isFloat
# func rndAtt(name, min, max, chance, isFloat=true):
# 	pass
# if sys.rndPer(chance):
# 	if not isFloat:
# 		att.set(name, sys.rndRan(min, max))
# 	else:
# 		att.set(name, sys.rndRan(min, max)/100.0)
# else:
# 	att.set(name, 0)

	
